<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<% String contextPath = request.getContextPath(); %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="${pageContext.request.contextPath}/resources/assets/css/bootstrap.min.css" rel="stylesheet" />
<link rel="stylesheet" href="${pageContext.request.contextPath}/resources/assets/css/font-awesome.min.css" />
<link rel="stylesheet" href="${pageContext.request.contextPath}/resources/assets/css/font-OpenSans.css" />
<style type="text/css">
	input.ace{
	 	cursor: pointer;
	    height: 20px;
	    opacity: 0;
	    position: absolute;
	    width: 18px;
	    z-index: 12;
	}
	input.ace[type="checkbox"] + .lbl, input.ace[type="radio"] + .lbl {
	    display: inline-block;
	    font-weight: normal;
	    line-height: 22px;
	    margin: 0;
	    min-height: 20px;
	    min-width: 20px;
	    position: relative;
	    z-index: 11;
	}
	label, .lbl {
	    vertical-align: middle;
	}
</style>
<script type="text/javascript">
	function submitForm($grid,$pjq,$pbq){
		var url;
		if($("#method").val()==="add")
		{
			url='<%=contextPath%>/privilege/add.action'
			$("#id").attr("name","parent.id");
		}
		else if($("#method").val()==="update")
		{
			url='<%=contextPath%>/privilege/update.action'
		}
		var param=$("#privilegeForm").serialize();
		console.info(param);
		$.post(url,  param, function(result) {
			if (result.success) {
				$grid.treegrid('reload');
			//	$pjq.find("#bsmodal").remove();
			} else {
				$pbq.alert(result.msg);
			}
		}, 'json');
	};
	$(function(){
		if($("#method").val()==="update")
		{
			$.getJSON('<%=contextPath%>/privilege/find.action',{'id':$("#id").val()},function(result){
				if(result.data.id!= undefined)
				{
					$("#form-pname").val(result.data.name);
					$("#form-purl").val(result.data.url);
					$("#form-pdescription").val(result.data.description);
					if(result.data.privilegeEnabled)
						$("#form-pprivilegeEnabled").prop('checked');
				}
				
			})
		}
		/* $("#form-pprivilegeEnabled").on('click',function(){
			if($(this).get(0).checked)
				$(this).val(true);
			else
				$(this).val(false);
		}) */
	})
</script>
</head>
<body>
<form id="privilegeForm" class="form-horizontal">
		<input id="id" type="hidden" name="id" value="${param.id}">
		<input id="method" type="hidden" value="${param.method}">
		<div class="form-group">
			<label class="col-sm-3 control-label no-padding-right" for="form-pname">权限名称：</label>
			<div class="col-sm-9">
				<input id="form-pname" name="name" class="form-control input-lg" type="text" placeholder="请输入权限名称">
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-3 control-label no-padding-right" for="form-purl">权限路径：</label>
			<div class="col-sm-9">
				<input id="form-purl" name="url"  class="form-control input-lg" type="text" placeholder="请输入权限路径">
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-3 control-label no-padding-right" for="form-pdescription">权限描述：</label>
			<div class="col-sm-9">
				<input id="form-pdescription" name="description" class="form-control input-lg" type="text" placeholder="请输入权限描述">
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-3 control-label no-padding-right" for="form-pprivilegeEnabled">启用权限：</label>
			<div class="col-sm-9">
				<input name="privilegeEnabled" value="true" type="checkbox" id="form-pprivilegeEnabled"  placeholder="是否启用该权限">
			</div>
		</div>
	</form>
	
</body>
</html>